Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added textract

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 21, 2026 2:32am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR adds AWS Textract integration for document OCR and analysis, along with several improvements to existing document processing blocks.

Key Changes:

  • New AWS Textract tool with sync (single-page) and async (multi-page) processing modes
  • Proper AWS SigV4 authentication implementation for direct Textract API calls
  • SSRF protection and input validation for external URLs and S3 URIs
  • New validateAwsRegion and validateS3BucketName security validators with comprehensive test coverage
  • Added S3 URI output (s3://bucket/key) to S3 put/copy operations for Textract async integration
  • Refactored File, Mistral Parser, Pulse, and Reducto blocks to use consistent basic/advanced mode UI pattern with canonicalParamId
  • Created V2 versions of File and Mistral Parser tools/blocks while preserving legacy versions (hidden from toolbar)
  • Fixed editor advanced options display logic to respect user toggle when editing
  • Added getS3InfoForKey helper for direct S3 access scenarios

Architecture Notes:

  • The Textract integration follows the established tool/block pattern with proper separation of concerns
  • Security validators are well-tested and follow AWS naming conventions
  • The basic/advanced mode refactoring improves UX consistency across document processing blocks

Confidence Score: 4/5

  • This PR is safe to merge with good security practices and follows established patterns
  • Score reflects well-structured code with proper input validation, SSRF protection, and comprehensive test coverage for new validators. Minor documentation inconsistencies noted but no blocking issues.
  • No files require special attention - the Textract API route has proper security measures in place

Important Files Changed

Filename Overview
apps/sim/app/api/tools/textract/parse/route.ts New Textract API route with AWS SigV4 authentication, sync/async processing modes, SSRF protection, and proper input validation. Well-structured with good security practices.
apps/sim/tools/textract/parser.ts Textract tool definition with proper params, request handling, and response transformation. Uses 'user-only' visibility for credentials as per project standards.
apps/sim/blocks/blocks/textract.ts Textract block definition with sync/async mode selector, file upload support, AWS credentials, and feature type toggles. Uses 'user-only' pattern for credentials.
apps/sim/lib/core/security/input-validation.ts Added validateAwsRegion and validateS3BucketName validators for AWS resource validation. Comprehensive pattern matching and security checks.
apps/sim/lib/core/security/input-validation.test.ts Comprehensive test coverage for new AWS region and S3 bucket name validators. Covers valid cases, edge cases, and security scenarios.
apps/sim/blocks/blocks/file.ts Added FileV2Block with simplified basic/advanced mode UI pattern. Legacy FileBlock marked as hidden. Uses createVersionedToolSelector for versioning.
apps/sim/blocks/blocks/mistral_parse.ts Added MistralParseV2Block with simplified UI pattern (basic/advanced modes). Legacy block hidden. Fixed TypeScript error typing from any to unknown.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/editor.tsx Fixed advanced options display logic - respects user toggle when editing, shows based on values when read-only.

Sequence Diagram

sequenceDiagram
    participant User
    participant TextractBlock
    participant TextractAPI as /api/tools/textract/parse
    participant StorageService
    participant AWSTextract as AWS Textract

    User->>TextractBlock: Configure block (credentials, mode, document)
    TextractBlock->>TextractAPI: POST request with params
    
    alt Sync Mode (single-page)
        TextractAPI->>TextractAPI: Validate inputs (region, URL)
        alt Internal File Path
            TextractAPI->>StorageService: Generate presigned URL
            StorageService-->>TextractAPI: Presigned download URL
        end
        TextractAPI->>TextractAPI: Fetch document bytes
        TextractAPI->>AWSTextract: AnalyzeDocument / DetectDocumentText
        AWSTextract-->>TextractAPI: Blocks response
    else Async Mode (multi-page)
        TextractAPI->>TextractAPI: Parse & validate S3 URI
        TextractAPI->>AWSTextract: StartDocumentAnalysis / StartDocumentTextDetection
        AWSTextract-->>TextractAPI: JobId
        loop Poll until complete
            TextractAPI->>AWSTextract: GetDocumentAnalysis / GetDocumentTextDetection
            AWSTextract-->>TextractAPI: JobStatus + Blocks
        end
    end
    
    TextractAPI-->>TextractBlock: Parsed blocks + metadata
    TextractBlock-->>User: Display results
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1
Copy link
Collaborator Author

@greptile

cursor[bot]

This comment was marked as outdated.

@waleedlatif1
Copy link
Collaborator Author

@greptile

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@waleedlatif1 waleedlatif1 changed the title feat(tools): added textract feat(tools): added textract, added v2 for mistral, updated tag dropdown Jan 21, 2026
cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator

@cursor review

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator

@cursor review

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit 563098c into staging Jan 21, 2026
11 checks passed
waleedlatif1 added a commit that referenced this pull request Jan 21, 2026
* fix(google): wrap primitive tool responses for Gemini API compatibility (#2900)

* fix(canonical): copilot path + update parent (#2901)

* fix(rss): add top-level title, link, pubDate fields to RSS trigger output (#2902)

* fix(rss): add top-level title, link, pubDate fields to RSS trigger output

* fix(imap): add top-level fields to IMAP trigger output

* improvement(browseruse): add profile id param (#2903)

* improvement(browseruse): add profile id param

* make request a stub since we have directExec

* improvement(executor): upgraded abort controller to handle aborts for loops and parallels (#2880)

* improvement(executor): upgraded abort controller to handle aborts for loops and parallels

* comments

* improvement(files): update execution for passing base64 strings (#2906)

* progress

* improvement(execution): update execution for passing base64 strings

* fix types

* cleanup comments

* path security vuln

* reject promise correctly

* fix redirect case

* remove proxy routes

* fix tests

* use ipaddr

* feat(tools): added textract, added v2 for mistral, updated tag dropdown (#2904)

* feat(tools): added textract

* cleanup

* ack pr comments

* reorder

* removed upload for textract async version

* fix additional fields dropdown in editor, update parser to leave validation to be done on the server

* added mistral v2, files v2, and finalized textract

* updated the rest of the old file patterns, updated mistral outputs for v2

* updated tag dropdown to parse non-operation fields as well

* updated extension finder

* cleanup

* added description for inputs to workflow

* use helper for internal route check

* fix tag dropdown merge conflict change

* remove duplicate code

---------

Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>

* fix(ui): change add inputs button to match output selector (#2907)

* fix(canvas): removed invite to workspace from canvas popover (#2908)

* fix(canvas): removed invite to workspace

* removed unused props

* fix(copilot): legacy tool display names (#2911)

* fix(a2a): canonical merge  (#2912)

* fix canonical merge

* fix empty array case

* fix(change-detection): copilot diffs have extra field (#2913)

* improvement(logs): improved logs ui bugs, added subflow disable UI (#2910)

* improvement(logs): improved logs ui bugs, added subflow disable UI

* added duplicate to action bar for subflows

* feat(broadcast): email v0.5 (#2905)

---------

Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com>
Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
Co-authored-by: Emir Karabeg <78010029+emir-karabeg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants